package com.lanou.renrenxin.tools;

import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.easemob.chat.EMChatManager;
import com.lanou.renrenxin.R;
import com.lanou.renrenxin.activity.VideoCallActivity;
import com.lanou.renrenxin.activity.VoiceCallActivity;

/**
 * Created by zouhui on 16/3/19.
 */
public class InstantCall {
    private String username;
    private Context context;

    public InstantCall(Context context, String username) {
        this.context = context;
        this.username = username;
    }

    /**
     * 拨打语音电话
     */
    public void startVoiceCall() {

        if (!EMChatManager.getInstance().isConnected()) {
            Toast.makeText(context, R.string.not_connect_to_server, Toast.LENGTH_SHORT).show();
        } else {
            context.startActivity(new Intent(context, VoiceCallActivity.class).putExtra("username", username)
                    .putExtra("isComingCall", false));
        }
    }

    /**
     * 拨打视频电话
     */
    public void startVideoCall() {
        if (!EMChatManager.getInstance().isConnected())
            Toast.makeText(context, R.string.not_connect_to_server, Toast.LENGTH_SHORT).show();
        else {
            context.startActivity(new Intent(context, VideoCallActivity.class).putExtra("username", username)
                    .putExtra("isComingCall", false));
        }
    }
}
